package cate.game.play.buff.h;


import cate.common.table.d.GDBuff;
import cate.game.play.buff.BuffHandler;
import cate.game.play.config.PlayCfgArgs;
import cate.game.play.proce.action.ctx.ActionCtx;
import easy.java.dev.note.NoteClass;
import easy.java.dev.note.NoteField;

@NoteClass("格挡盾BH")
public class 格挡盾BH extends BuffHandler {

	@NoteField("格挡次数")
	private int blockTimeMax;

	@Override
	public void parse(String code) {
		// 格挡次数=3
		PlayCfgArgs args = new PlayCfgArgs(code);
		this.blockTimeMax = args.getInt("格挡次数", 1);
	}

    //当前格挡次数
	private int curBlockTime;

	//剩余格挡次数
	private int leftTime() {
		return blockTimeMax - curBlockTime;
	}

	@Override
	public boolean hurtBlock(ActionCtx action) {
		if (leftTime() > 0) {
			curBlockTime++;
			if (leftTime() <= 0) {
				this.buff.markInvalid(action, GDBuff.InvalidReason.EXHAUSTED);
			}
			return true;
		} else {
			return false;
		}
	}
}
